home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmassoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  2.0 KB  |  53 lines

  1. // CmAssoc.h
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Association definition.
  7. // -----------------------------------------------------------------
  8.  
  9. #ifndef _CMASSOC_H
  10. #define _CMASSOC_H
  11.  
  12. #include <cm/include/cmobject.h>
  13.  
  14. class CmAssociation : public CmObject {           // Association definition.
  15. public:
  16.   CmAssociation(CmObject*, CmObject*);            // Association constructor.
  17.   CmAssociation(const CmAssociation&);            // Copy constructor.
  18.  ~CmAssociation() {}                              // Association destructor.
  19.  
  20.   CmAssociation& operator=(const CmAssociation&); // Assignment operator.
  21.  
  22.   CmObject* key   () const;                       // Key access.
  23.   CmObject* object() const;                       // Object access.
  24.   void      object(CmObject* O);                  // Set object.
  25.  
  26.   Bool     isEqual(CmObject*) const;              // Compare objects.
  27.   int      compare(CmObject*) const;              // Compare objects.
  28.   unsigned hash   (unsigned)  const;              // Hash function.
  29.   void     printOn(ostream&)  const;              // Print on stream.
  30.   Bool     write  (CmReserveFile&) const;         // Write to reserve file.
  31.   Bool     read   (CmReserveFile&);               // Read from reserve file.
  32.  
  33.   CMOBJECT_DEFINE(CmAssociation, CmObject)        // Define object funcs.
  34.  
  35. protected:
  36.   CmObject *_key;                                 // Association key.
  37.   CmObject *_object;                              // Association object.
  38. };
  39.  
  40. // "key" returns the key value.
  41. inline CmObject* CmAssociation::key() const
  42. { return _key; }
  43.  
  44. // "object" returns the object value.
  45. inline CmObject* CmAssociation::object() const
  46. { return _object; }
  47.  
  48. // "object" sets a new object value.
  49. inline void CmAssociation::object(CmObject* O)
  50. { _object = O; }
  51.  
  52. #endif
  53.